package com.zjitc;

import com.zaxxer.hikari.HikariDataSource;
import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/7 14:29
 * @description:
 */
@Configuration
@Import(DataSourceProperties.class)
public class DataSourceConfiguration2 {

  @Bean
  public DataSource dataSource(DataSourceProperties prop) {
    HikariDataSource ds = new HikariDataSource();

    ds.setDriverClassName(prop.getDriverClass());
    ds.setPassword(prop.getPassword());
    ds.setUsername(prop.getUsername());
    ds.setJdbcUrl(prop.getJdbcUrl());

    System.out.println(prop.getNumber());

    return ds;
  }
}
